function t(t, e) {
    this.errMsg = t, this.code = e;
}

Component({
    lifetimes: {
        attached: function() {
            this._initDateTimePickerFn();
        },
        detached: function() {}
    },
    attached: function() {
        this._initDateTimePickerFn();
    },
    detached: function() {},
    options: {
        multipleSlots: !0
    },
    properties: {
        mode: {
            type: String,
            require: !0
        },
        value: {
            type: String,
            value: ""
        }
    },
    data: {
        rangeList: [],
        rangeValue: [],
        dateDetails: [ "年", "月", "时", "分", "秒" ]
    },
    methods: {
        _initDateTimePickerFn: function() {
            var e = this;
            try {
                var i = this.data, a = i.value, n = i.mode;
                if ("dateminute" != n && "datetime" != n) throw new t("请输入合法的时间选择器类型！", -1);
                var s = this._validateShowTime(a, n), r = s.substring(0, s.indexOf("-")), u = s.split(" ")[0].split("-")[1], o = this._gotDateTimeList({
                    _start: Number(r) - 100,
                    _end: Number(r) + 100,
                    _type: 0
                }), d = this._gotDateTimeList({
                    _start: 1,
                    _end: 12,
                    _type: 1
                }), h = this._gotDayList(r, u), g = this._gotDateTimeList({
                    _start: 0,
                    _end: 23,
                    _type: 2
                }), c = this._gotDateTimeList({
                    _start: 0,
                    _end: 59,
                    _type: 3
                }), l = this._gotDateTimeList({
                    _start: 0,
                    _end: 59,
                    _type: 4
                }), _ = new Array();
                _.push(o), _.push(d), _.push(h), _.push(g), _.push(c), "datetime" === n && _.push(l), 
                this.setData({
                    rangeList: _
                }, function() {
                    e._echoDateTime(s);
                });
            } catch (t) {
                console.log(t);
            }
        },
        _validateShowTime: function(t, i) {
            var a = e(new Date()).replace(/\//g, "-"), n = t.trim() || a, s = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/, r = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/;
            return "dateminute" === i ? (s.test(n) && (n = n.substring(0, n.lastIndexOf(":"))), 
            r.test(n) || (n = a.substring(0, a.lastIndexOf(":")))) : (r.test(n) && (n += ":00"), 
            s.test(n) || (n = a)), n;
        },
        _gotDateTimeList: function(t) {
            for (var e = t._start, i = t._end, a = t._type, n = new Array(), s = e; s <= i; s++) n.push(this._addZore(s) + this.data.dateDetails[a]);
            return n;
        },
        _gotDayList: function(t, e) {
            for (var i = new Date(t, e, 0).getDate(), a = new Array(), n = 1; n <= i; n++) a.push(this._addZore(n) + "日");
            return a;
        },
        _addZore: function(t) {
            return t < 10 ? "0" + t : t.toString();
        },
        _echoDateTime: function(t) {
            var e = this.data.rangeList, i = new Array();
            t.split(/[\-|\:|\s]/).map(function(t, a) {
                e[a].map(function(e, a) {
                    -1 !== e.indexOf(t) && i.push(a);
                });
            }), this.setData({
                rangeValue: i
            });
        },
        selectChangeFn: function(t) {
            var e = t.detail.value, i = this.data.rangeList, a = "";
            e.map(function(t, n) {
                a += i[n][t].substring(0, i[n][t].length - 1), 0 == n || 1 == n ? a += "-" : 3 == n || 4 == n && n != e.length - 1 ? a += ":" : 2 == n && n != e.length - 1 && (a += " ");
            }), this.triggerEvent("change", {
                value: a
            });
        },
        selectColumnChangeFn: function(t) {
            var e = t.detail, i = e.column, a = e.value, n = this.data, s = n.rangeList, r = n.rangeValue, u = Number(s[i][a].substring(0, s[i][a].length - 1));
            if (1 === i) {
                var o = Number(s[0][r[0]].substring(0, s[0][r[0]].length - 1)), d = this._gotDayList(o, u);
                s[i + 1] = d;
            }
            this.setData({
                rangeList: s
            });
        }
    }
});

var e = function(t) {
    var e = t.getFullYear(), a = t.getMonth() + 1, n = t.getDate(), s = t.getHours(), r = t.getMinutes(), u = t.getSeconds();
    return [ e, a, n ].map(i).join("/") + " " + [ s, r, u ].map(i).join(":");
}, i = function(t) {
    return (t = t.toString())[1] ? t : "0" + t;
};